import { create, StateCreator } from 'zustand';
import { devtools } from 'zustand/middleware';
import { immer } from 'zustand/middleware/immer';
import type { State,CustomRecord } from './types';
export type Actions = {
};

export type Store = State<CustomRecord> & Actions;
export const createStore: StateCreator<Store, [['zustand/immer', never]]> = (set, get) => ({
  typeDetailData:{
    id:null,
    code: '',
    name: '',
    createdBy: '',
    createdTime: '',
    updatedBy: '',
    updatedTime: '',
    remark: '',
  },
  // 新增/编辑指标类型弹窗
  addOrEditTypeModal: {
    open: false, // 弹窗开关
  },
  // 指标类型详情弹窗
  detailTypeModal: {
    open: false, // 弹窗开关
  },
})

export const useStore = create<Store>()(devtools(immer<Store>(createStore)));